﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace _619BJP.Web
{
    // 注意: 有关启用 IIS6 或 IIS7 经典模式的说明，
    // 请访问 http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
               "home", // 路由名称
               "product.{id}.htm", // 带有参数的 URL
               new { controller = "Product", action = "ProductDetails", id = UrlParameter.Optional } // 参数默认值
           );
            routes.MapRoute(
              "productdetails", // 路由名称
              "home.html", // 带有参数的 URL
              new { controller = "Home", action = "ProductDetails", id = UrlParameter.Optional } // 参数默认值
          );
            routes.MapRoute(
                "comparison", // 路由名称
                "product.{id}.htm", // 带有参数的 URL
                new { controller = "Product", action = "ProductComparison", id = 0} // 参数默认值
            );
            routes.MapRoute(
               "branddetails", // 路由名称
               "brand.{id}.htm", // 带有参数的 URL
               new { controller = "Brand", action = "BrandDetails", id = UrlParameter.Optional } // 参数默认值
           );
            routes.MapRoute(
               "articledetails", // 路由名称
               "article.{id}.htm", // 带有参数的 URL
               new { controller = "Article", action = "ArticleDetails", id = UrlParameter.Optional } // 参数默认值
           );
            routes.MapRoute(
                "articleSearch", // 路由名称
                "{id}/{keyword}", // 带有参数的 URL
                new { controller = "Article", action = "ArticleList", id = 0}, // 参数默认值
                new { id = "0|1|2|3|4|5|6|7|8"}
            );

            routes.MapRoute(
                "Default", // 路由名称
                "{controller}/{action}/{id}", // 带有参数的 URL
                new { controller = "Home", action = "Index", id = UrlParameter.Optional } // 参数默认值
            );

        }

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RegisterRoutes(RouteTable.Routes);
        }
    }
}